/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Alvaro
 */
@Entity
@Table(name = "company_order")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompanyOrder.findAll", query = "SELECT c FROM CompanyOrder c"),
    @NamedQuery(name = "CompanyOrder.findByIdCompanyOrder", query = "SELECT c FROM CompanyOrder c WHERE c.idCompanyOrder = :idCompanyOrder"),
    @NamedQuery(name = "CompanyOrder.findByDate", query = "SELECT c FROM CompanyOrder c WHERE c.date = :date"),
    @NamedQuery(name = "CompanyOrder.findByAmount", query = "SELECT c FROM CompanyOrder c WHERE c.amount = :amount"),
    @NamedQuery(name = "CompanyOrder.findByIsPayed", query = "SELECT c FROM CompanyOrder c WHERE c.isPayed = :isPayed")})
public class CompanyOrder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_COMPANY_ORDER")
    private Integer idCompanyOrder;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "AMOUNT")
    private BigDecimal amount;
    @Basic(optional = false)
    @NotNull
    @Column(name = "IS_PAYED")
    private boolean isPayed;
    @JoinColumn(name = "COMPANY", referencedColumnName = "ID_COMPANY")
    @ManyToOne(optional = false)
    private Company company;
    @JoinColumn(name = "COMPANY_PRODUCT", referencedColumnName = "ID_COMPANY_PRODUCT")
    @ManyToOne(optional = false)
    private CompanyProduct companyProduct;

    public CompanyOrder() {
    }

    public CompanyOrder(Integer idCompanyOrder) {
        this.idCompanyOrder = idCompanyOrder;
    }

    public CompanyOrder(Integer idCompanyOrder, Date date, BigDecimal amount, boolean isPayed) {
        this.idCompanyOrder = idCompanyOrder;
        this.date = date;
        this.amount = amount;
        this.isPayed = isPayed;
    }

    public Integer getIdCompanyOrder() {
        return idCompanyOrder;
    }

    public void setIdCompanyOrder(Integer idCompanyOrder) {
        this.idCompanyOrder = idCompanyOrder;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public boolean getIsPayed() {
        return isPayed;
    }

    public void setIsPayed(boolean isPayed) {
        this.isPayed = isPayed;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public CompanyProduct getCompanyProduct() {
        return companyProduct;
    }

    public void setCompanyProduct(CompanyProduct companyProduct) {
        this.companyProduct = companyProduct;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompanyOrder != null ? idCompanyOrder.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompanyOrder)) {
            return false;
        }
        CompanyOrder other = (CompanyOrder) object;
        if ((this.idCompanyOrder == null && other.idCompanyOrder != null) || (this.idCompanyOrder != null && !this.idCompanyOrder.equals(other.idCompanyOrder))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CompanyOrder[ idCompanyOrder=" + idCompanyOrder + " ]";
    }
    
}
